﻿using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using T.ApiResults;
using T.Personnel.Domain;
using T.Personnel.Domain.Dto;
using T.Personnel.Read.API.Application.Command.FullManageCommand;

namespace T.Personnel.Read.API.Controllers
{
    /// <summary>
    /// 人事管理-转正办理-读
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class ReadFullManageController : ControllerBase
    {
        private readonly IMediator mediator;

        public ReadFullManageController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 获取转正列表
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<Result<Manage>>> GetListFullManageAsync([FromQuery] GetListFullManageCommand command)
        {
            ApiResult<Result<Manage>> result = new ApiResult<Result<Manage>>();
            try
            {
                result.Data = await mediator.Send(command);
                return result;
            }
            catch (Exception ex)
            {
                result.Code = 500;
                result.Message = ex.Message;
                throw;
            }
        }

        /// <summary>
        /// 获取转正反填
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<Manage>> GetFullManageAsync([FromQuery]GetFullManageCommand command)
        {
            ApiResult<Manage> result = new ApiResult<Manage>();
            try
            {
                result.Data = await mediator.Send(command);
                return result;
            }
            catch (Exception ex)
            {
                result.Code = 500;
                result.Message = ex.Message;
                throw;
            }
        }

        /// <summary>
        /// 获取审批转正列表
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<Result<Manage>>> GetListFullsManageAsync([FromQuery] GetListFullsManageCommand command)
        {
            ApiResult<Result<Manage>> result = new ApiResult<Result<Manage>>();
            try
            {
                result.Data = await mediator.Send(command);
                return result;
            }
            catch (Exception ex)
            {
                result.Code = 500;
                result.Message = ex.Message;
                throw;
            }
        }
    }
}
